// -*- coding: utf-8 -*-

#include <gtest/gtest.h>

#include <iostream>
#include <vector>
#include <boost/shared_ptr.hpp>

#include "elisa/elisa_interval_gaol.h"

/// 区間ラッパーのテスト。

using namespace std;
using namespace elisa;

class IntervalTest : public testing::Test
{
public:
	Interval a, b, c, d;

protected:
	IntervalTest() 
		: a(), b(0), c(1), d(1, 1.5)
	{
	}

	virtual ~IntervalTest() 
	{
	}
};

TEST_F(IntervalTest, Init)
{
	ASSERT_EQ(Interval::Universe, a);

	ASSERT_EQ(0.0, b.inf());
	ASSERT_EQ(0.0, b.sup());

	ASSERT_EQ(Interval(1.0, 1.0), c);

	ASSERT_EQ(Interval(1, 1.5), d);
}

TEST_F(IntervalTest, Arith)
{
	ASSERT_EQ(Interval::Universe, a+c);

	ASSERT_EQ(-0.5, (d-d).inf());
	ASSERT_EQ(0.5,  (d-d).sup());
	ASSERT_EQ(Interval(0, 0.5),  abs(d-d));

	ASSERT_EQ(Interval(-2.0, -1.5), Interval(d-3));
	ASSERT_EQ(0.0,  (Interval(c*2*(1.0-d))).sup());
}

TEST_F(IntervalTest, NonArith)
{
	ASSERT_TRUE(1.0 == (b+c).inf());
}
